package com.xiaoihu.server.pojo;

import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
//@AllArgsConstructor
@ApiModel(value="公共返回对象", description="")
public class RespBean {

	private Integer code;
	private String message;
	private Object obj;

	public static RespBean build() {
		return new RespBean();
	}


	public Integer getCode() {
		return code;
	}

	public RespBean setCode(Integer code) {
		this.code = code;
		return this;
	}

	public String getMessage() {
		return message;
	}

	public RespBean setMessage(String message) {
		this.message = message;
		return this;
	}

	public Object getObj() {
		return obj;
	}

	public RespBean setObj(Object obj) {
		this.obj = obj;
		return this;
	}

	public RespBean(Integer code, String message, Object obj) {
		this.code = code;
		this.message = message;
		this.obj = obj;
	}

	/**
	 * 成功，带信息
	 * @param message
	 * @return
	 */
	public static RespBean success(String message){
		return new RespBean(200,message,null);
	}


	/**
	 * 成功，带信息和对象
	 * @param message
	 * @return
	 */
	public static RespBean success(String message,Object obj){
		return new RespBean(200,message,obj);
	}

	/**
	 * 失败，带信息
	 * @param message
	 * @return
	 */
	public static RespBean error(String message){
		return new RespBean(500,message,null);
	}


	/**
	 * 失败，带信息和对象
	 * @param message
	 * @return
	 */
	public static RespBean error(String message,Object obj){
		return new RespBean(500,message,obj);
	}
}